@ECHO OFF

:BEGIN
goto START

:CONFIG
SET JUNCTION_CMD=mklink /J

call :LINK .config
call :LINK ssh .ssh
call :LINK vim vimfiles

goto END


:START
if "%~1" == "" set DST=%USERPROFILE%
IF "%~2" == "" SET SRC1=%FS_ROOT%
if "%SRC1%" == "" SET SRC=%CD%
if NOT "%SRC1%" == "" SET SRC=%SRC1%\Appdata
goto CONFIG

:LINK
set fn1=%1
set fn2=%2
if "%2" == "" set fn2=%1
echo.
echo Linking to %DST%\%fn2%
echo       from %SRC%\%fn1%
if exist "%DST%\%fn2%" goto LINK_SKIP
%JUNCTION_CMD% "%DST%\%fn2%" "%SRC%\%fn1%"
goto :eof
goto END
:LINK_SKIP
echo Skiped, target exists.
goto :eof

:END
